package pri.zxx.nio;

import lombok.SneakyThrows;
import org.junit.jupiter.api.Test;


import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;

/**
 * @author Twilight
 * @desc nio 工具类
 * @createTime 2020-05-14-21:36
 */
public class FileInLine {
	public static void main(String[] args) {
		Path filePath = Paths.get("d:/", "data.txt");
		try {
			Stream<String> lines = Files.lines(filePath);
			lines.forEach(System.out::println);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}


	@SneakyThrows
	@Test
	public void test() {
		Path filePath = Paths.get("d:/");
		Files.list(filePath).forEach(System.out::println);
	}

	@SneakyThrows
	@Test
	public void test1() {
		Path filePath = Paths.get("d:/");
		Files.list(filePath).filter(Files::isDirectory).forEach(System.out::println);
		System.out.println("------------以下为文件-----------------");
		Files.list(filePath).filter(Files::isRegularFile).forEach(System.out::println);
	}


}
